// utils/scrollUtils.js
export function hasVerticalScroll(context = null) {
  // H5 环境优先使用 DOM API
  if (typeof document !== 'undefined') {
    return document.documentElement.scrollHeight > 
           document.documentElement.clientHeight
  }

  // 非H5环境使用节点查询
  return new Promise((resolve) => {
    const query = uni.createSelectorQuery().in(context || this)
    const selectors = ['.uni-page-body', 'page']
    
    const queryNext = (index) => {
      if (index >= selectors.length) {
        resolve(false)
        return
      }
      
      query.select(selectors[index]).boundingClientRect(rect => {
        if (rect && rect.height > Math.floor(rect.height) + 1) {
          resolve(true)
        } else {
          queryNext(index + 1)
        }
      }).exec()
    }
    
    queryNext(0)
  })
}